/**
 * @Author: cest
 * @Date: 2022-08-04 10:08:04
 * @LastEditTime: 2022-08-04 10:20:34
 * @LastEditors: cest
 * @FilePath: /vue3-todo-list/src/hooks/useGetters.js
 * @Description: 编辑描述内容
 */
/**
 * @Author: cest
 * @Date: 2022-08-04 09:46:53
 * @LastEditTime: 2022-08-04 10:06:50
 * @LastEditors: cest
 * @FilePath: /vue3-todo-list/src/hooks/useState.js
 * @Description: 编辑描述内容
 */
import { mapGetters, createNamespacedHelpers } from 'vuex'
import { mapper } from './useMapper'

export const useGetters = (spaceName, pMapArry) => {
  let mapArry = pMapArry
  let mapFn = mapGetters
  if (typeof spaceName === 'string' && spaceName.length > 0) {
    mapFn = createNamespacedHelpers(spaceName).mapGetters
  } else {
    mapArry = spaceName
  }
  return mapper(mapArry, mapFn)
}
export default useGetters
